{include file='header'/}
<body>
<form class="layui-form" action="javascript:;">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label required">选择模型</label>
                <div class="layui-input-inline">
                    <select name="model_id" lay-verify="required">
                        <option value="">请选择模型</option>
                        {foreach models_list as $key=>$val}
                        <option value="{$val.id}">{$val.name}</option>
                        {/foreach}
                    </select>
                </div>
                <div class="layui-form-mid layui-text-em">
                    <i class="layui-icon layui-icon-survey" id="model_id_tips"
                       onmouseover="show('选择要生成地图的模型','model_id_tips')" onmouseleave="close_tips()"></i>
                </div>
            </div>

            <div class="layui-form-item hui-explain-box">
                <label class="layui-form-label required">优先权</label>
                <div class="layui-input-inline">
                    <select name="priority" lay-verify="required">
                        <option value="">请选择优先权</option>
                        <option value="1">1</option>
                        <option value="0.9">0.9</option>
                        <option value="0.8" selected>0.8</option>
                        <option value="0.7">0.7</option>
                        <option value="0.6">0.6</option>
                        <option value="0.5">0.5</option>
                        <option value="0.4">0.4</option>
                        <option value="0.3">0.3</option>
                        <option value="0.2">0.2</option>
                        <option value="0.1">0.1</option>
                    </select>
                </div>
                <div class="layui-form-mid layui-text-em">
                    <i class="layui-icon layui-icon-survey" id="priority_tips"
                       onmouseover="show('搜索引擎抓取的优先级。数字越大，优先级越高','priority_tips')"
                       onmouseleave="close_tips()"></i>
                </div>
            </div>

            <div class="layui-form-item hui-explain-box">
                <label class="layui-form-label required">更新频率</label>
                <div class="layui-input-inline">
                    <select name="change_freq" lay-verify="required">
                        <option value="always">一直更新</option>
                        <option value="hourly">小时</option>
                        <option value="daily">天</option>
                        <option value="weekly" selected>周</option>
                        <option value="monthly">月</option>
                        <option value="yearly">年</option>
                        <option value="never">从不更新</option>
                    </select>
                </div>
                <div class="layui-form-mid layui-text-em">
                    <i class="layui-icon layui-icon-survey" id="change_freq_tips"
                       onmouseover="show('告诉搜索引擎您的网站更新频率','change_freq_tips')"
                       onmouseleave="close_tips()"></i>
                </div>
            </div>

            <div class="layui-form-item hui-explain-box">
                <label class="layui-form-label required">更新频率</label>
                <div class="layui-input-block">
                    <input type="radio" name="limit_total" value="0" title="不限制" checked>
                    <input type="radio" name="limit_total" value="9000" title="禁用">
                    <input type="radio" name="limit_total" value="9000" title="一万条">
                    <input type="radio" name="limit_total" value="29000" title="三万条">
                    <input type="radio" name="limit_total" value="49000" title="五万条">
                </div>
            </div>

            <div class="layui-form-item hui-explain-box">
                <label class="layui-form-label required">文件格式</label>
                <div class="layui-input-block">
                    <input type="radio" name="type" value="0" title="XML格式" checked>
                    <input type="radio" name="type" value="1" title="TXT格式">
                </div>
            </div>

            {notempty name="is_make_xml"}
            <div class="layui-form-item hui-explain-box">
                <label class="layui-form-label">sitemap.xml</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-text-em">
                        更新时间：2024-10-22 14:31:42 &emsp;
                        <button class="layui-btn layui-btn-xs layui-btn-danger"
                                data-delete="{:url('delete',['type'=>'xml'])}" data-reload="2">
                            删除文件
                        </button>
                        <a class="layui-btn layui-btn-xs layui-btn-blue" href="/sitemap.xml" target="_blank">
                            查看文件
                        </a>
                    </div>
                </div>
            </div>
            {/notempty}

            {notempty name="is_make_txt"}
            <div class="layui-form-item hui-explain-box">
                <label class="layui-form-label">sitemap.txt</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-text-em">
                        更新时间：2024-10-22 14:31:42 &emsp;
                        <button class="layui-btn layui-btn-xs layui-btn-danger"
                                data-delete="{:url('delete',['type'=>'txt'])}" data-reload="2">
                            删除文件
                        </button>
                        <a class="layui-btn layui-btn-xs layui-btn-blue" href="/sitemap.txt" target="_blank">
                            查看文件
                        </a>
                    </div>
                </div>
            </div>
            {/notempty}

            <div class="layui-form-item hui-explain-box" style="padding-top:30px;">
                <label class="layui-form-label"></label>
                <div class="layui-input-block">
                    <button class="layui-btn" onclick="make_sitemap()">开始生成</button>
                </div>
            </div>

        </div>
    </div>
</form>

{include file='footer'/}
<script>
  layui.use(['form', 'jquery'], function () {
    let form = layui.form;
    let $ = layui.jquery;
    var layer = layui.layer;
    var util = layui.util;

    window.show = function (msg, id) {
      layer.tips('' + msg, '#' + id, {tips: [2, 'black']});
    }
    window.close_tips = function () {
      layer.closeAll('tips');
    }

    window.make_sitemap = function () {
      //layer.load(2);
      $.ajax({
        type: 'POST',
        url: '{:url("make_sitemap")}',
        data: $('form').serialize(),
        dataType: "json",
        success: function (res) {
          layer.closeAll('loading');
          if (res.code === 200) {
            return hui_msg(res.msg, 1, function () {
              location.reload();
            });
          } else if (res.code === 2) {
            return hui_msg(res.msg, 3);
          } else {
            return hui_msg(res.msg, 2)
          }

        }
      })
    }

  })
</script>
</body>
</html>
